<!DOCTYPE html>
<html>

<head lang="en">
	<title>首页</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
	<link rel="stylesheet" href="/css/reset.css" rel="stylesheet" >
	<link rel="stylesheet" href="/css/index.css" rel="stylesheet">
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<link rel="stylesheet" href="js/plugins/ui/jquery-ui.min.css">
	<script src="js/plugins/ui/jquery-ui.min.js"></script>
	<link rel="stylesheet" href="js/plugins/ui/jquery-ui.theme.min.css">
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
	<!--<style>
		html {
			width: 100%;
			height: auto;
			overflow-x: hidden;
		}

		body {
			text-align: left;
			width: 100%;
			/*background: #e9583e;*/
			overflow-y: scroll;
		}
	</style>-->

	<script>

        $(function () {
            $("#tags").val("");
            //滑动分页
            var currentPage = 1;
            var dataList = [];
            var totalPage = 1;
            //日报
            //获取推荐的日报
            $.get("/news/commends", {currentPage: currentPage, pageSize: 3}, function (data) {
                //console.log(data);
                var slice = data.list.slice(1, data.list.length);
                //console.log(slice);
                //渲染第一个推荐资讯
                $("#commedNews").renderValues(data.list[0],{
                    setHref: function (item, value) {
                        $(item).attr("href", $(item).attr("href") + value);
                    }
                });
                //遍历渲染从第二个开始的推荐资讯
                $("#smaller").renderValues({list: slice},{
                    setHref: function (item, value) {
                        $(item).attr("href", $(item).attr("href") + value);
                    }
                });
                currentPage += 1;
                totalPage = data.pages;

            });
            /*$(window).scroll(function () {
                if ($(window).height() + $(window).scrollTop() + 1 >= $(document).height()) {
                    if (currentPage <= totalPage) {
                        $.get("/news/commends", {currentPage: currentPage, pageSize: 2}, function (data) {
                                $.merge(dataList, data.list);
                                $("#smaller").renderValues({list: dataList},{
                                    setHref: function (item, value) {
                                        $(item).attr("href", $(item).attr("href") + value);
                                    }
                                });
                                currentPage += 1;
                            }
                        )
                    } else {
                        $(document).dialog({
                            type : 'notice',
                            infoText: '亲.我也是有限度的',
                            autoClose: 2500,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }
                }
            });*/

			showComments();

			$.get("/travels/commends",{type:1,pageSize:3},function (data) {
                //console.log(data);
                $("#travelsCommends").renderValues(data,{
                    setHref:function (item, value) {
                        $(item).attr("href",($(item).attr("href")+value));
                    }
				})
				$(".carousel-item:first").addClass("active");
            })
        })

		function showComments(){
			var Mar = document.getElementsByClassName("Marquee")[0];
			var child_div=Mar.getElementsByTagName("div");
			var picH = 50;//移动高度
			var scrollstep=3;//移动步幅,越大越快
			var scrolltime=20;//移动频度(毫秒)越大越慢
			var stoptime=3000;//间断时间(毫秒)
			var tmpH = 0;
			Mar.innerHTML += Mar.innerHTML;
			function start(){
				if(tmpH < picH){
					tmpH += scrollstep;
					if(tmpH > picH )tmpH = picH ;
					Mar.scrollTop = tmpH;
					setTimeout(start,scrolltime);
				}else{
					tmpH = 0;
					Mar.appendChild(child_div[0]);
					Mar.scrollTop = 0;
					setTimeout(start,stoptime);
				}
			}
			setTimeout(start,stoptime)
		}

        //注意发送ajax请求需要时间(滞后性)-----------------------找攻略搜索框------------
        var sdata;
        var tdata;
        $.get("/strategies/search",function (data) {
            sdata=data;
            $.get("/travels/search",function (data1) {
                tdata=data1;
                $.merge(data,data1);
            })
            $( "#tags" ).autocomplete({
                source: data
            });
        });

        //搜索栏找攻略
        function myFunction() {
            var k =1;
            var title = $("#tags").val();
            $.each(tdata,function (index, ele) {
				if(ele==title){
				    k=0;
				}
            })
            if(k){
                $.get("/strategies/titles",{title:title},function (data) {
                    console.log(data);
                    setTimeout(function () {
                        location.href="/strategyCatalogs.html?id="+data.id;
                    },1000)
                });
			}else{
                $.get("/travels/titles",{title:title},function (data) {
                    setTimeout(function () {
                        location.href = "travelContent.html?id=" +data.id
                    },1000)
                })
			}



        }
	</script>



</head>
<body>
<div class="body">
	<input type="checkbox" id="menu">

	<label for="menu" class="menu">
		<span><i class="fa fa-user fa-fw fa-2x"></i></span>
		<span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
	</label>
	<!-- 侧边栏 -->
	<div class="nav">
		<iframe id="ipage" src="/mine/simpleProfiles.html" frameborder="0" width="90%"></iframe>
	</div>
	<div class="search-head">
		<div class="row nav-search">
			<div class="col-2"></div>
			<div class="col-10">
				<div class="input-group-sm search">
					<input class="form-control searchBtn"  type="search" onsearch="myFunction()" id="tags"  placeholder="搜索旅行攻略、日记和旅游资讯">
				</div>
			</div>
		</div>
	</div>

	<div class="container">
		<h6 class="module-title">每周推荐</h6>
		<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
			<div id="travelsCommends">

				<div class="carousel-inner" render-loop="list">

					<div class="carousel-item">
						<a href="/travelContent.html?id=" render-fun="setHref" render-key="list.travelId">
							<img class="d-block w-100"  render-src="list.commendCoverUrl" width="100%" height="200px">
							<span class="recommend" render-html="list.commendTitle" ></span>
						</a>
						<div class="recommend-author">
                        <a href="#">
                            <img  class="rounded-circle" style="width: 10%;" render-src="list.headImgUrl">
                            <span render-html="list.nickName"></span>
						</a>在&nbsp;
							<span render-html="list.placeName"></span>
						</div>
					</div>
				</div>
			</div>


			<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
				<span class="carousel-control-prev-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
			<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
				<span class="carousel-control-next-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
		</div>
		<hr>

		<div class="row nav-box">
			<div class="col" style="background-color: #DFE823;" align="center">
				<a href="strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
			</div>
			<div class="col" style="background-color: #7281D5;" align="center">
				<a href="travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
			</div>
			<div class="col" style="background-color: #4eccc4;" align="center">
				<a href="/hotelsearching.html"><i class="fa fa-hotel fa-fw"></i> 寻住处</a>
			</div>
		</div>

		<div class="row dynamic " id="comments">
			<div class="col-1" style="padding: 0px;">
				<img class="rounded" src="/img/topComment.png" style="width: 50px;">
			</div>
			<div class="col">
				<div class="Marquee"  >
					<div class="d-flex">
					<a href="userProfiles.html?id=" >
						<img  class="rounded-circle dynamic-head" src="/upload/6610317b-2077-4bd3-98c7-7d31b6613469.jpg">
					</a>
					<a href="strategyComment.html"  class="dynamic-detail" data-id="1">
						<span>叩丁狼</span> 点评了攻略<p >广州攻略</p>
					</a>
				</div><div class="d-flex">
					<a href="userProfiles.html" >
						<img class="rounded-circle dynamic-head" src="/upload/23a45130-e59c-4844-bc52-67aed3d57fc1.jpeg">
					</a>
					<a href="strategyComment.html"  class="dynamic-detail" >
						<span >dafei</span> 点评了攻略<p >广州攻略</p>
					</a>
				</div></div>
			</div>
		</div>
	</div>

	<hr>

    <div class="container">
        <h6 class="module-title">骡窝日报 <a href="newsPage.html">更多</a></h6>
        <div id="commedNews">
            <div class="news " id="bigger">
                <a href="newsContent.html?id=" render-fun="setHref" render-key="id">
                    <img width="100%" render-src="coverUrl">
                    <div class="caption">
                        <h5 render-html="title"></h5>
                        <p render-html="summary">
                        </p>
                    </div>
                </a>
            </div>
        </div>
        <hr>
        <div id="smaller">
            <div render-loop="list">
                <div style="margin-bottom: 20px">
                    <a href="newsContent.html?id=" render-fun="setHref" render-key="list.id">
                        <div class="row news-detail">
                            <div class="col-7">
                                <img width="150%" render-src="list.coverUrl">
                            </div>
                            <div class="col-5">
                                <h4 render-html="list.title"></h4>
                                <p render-html="list.summary"></p>
                            </div>
                        </div>
                    </a>
                    <hr>
                </div>
            </div>
        </div>
    </div>
</div>



</body>

</html>